import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import CryptoJS  from 'crypto-js'
import './style/element-variables.scss'
// import 'element-ui/lib/theme-chalk/index.css'
import './style/index.scss'
import '@/icons' // icon
import '@/permission' // permission 权限控制

import 'default-passive-events'

import Watermark  from 'watermark-plus'
const watermark = new Watermark({
  // 传参
  content: '3DM广告后台系统',
});
// 创建水印
watermark.create();
Vue.config.productionTip = false
require ('./mock/index')
import i18n from './lang' 
// Vue.use(ElementUI, {   i18n: (key, value) => i18n.t(key, value) })
Vue.use(ElementUI)

Vue.prototype.$md5 = function (value) {
  return CryptoJS.MD5(value).toString();
};
new Vue({
  i18n,
  router,
  store,
  render: h => h(App)
}).$mount('#app')

// 时间戳转换时间
Vue.prototype.$newdata  = function (str) {
  // let time = parseInt(new Date().getTime() / 1000);
  return str.replace(/^\s*|\s*$/g, '');
};


// 时间转化时间戳
Vue.prototype.$formateDate  = function (time) {
  let date;
     date = new Date(time * 1000); // 13位时间戳乘1转数字
  let y = date.getFullYear(); //获取年份
  let month = date.getMonth() + 1; //获取月份
  let m = month < 10 ? "0" + month : month; //月份不满10天显示前加0
  let day = date.getDate(); //获取日期
  let d = day < 10 ? "0" + day : day; //日期不满10天显示前加0
  let h = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(); //小时
  let mm =
    date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); //分
  let ss =
    date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); //秒
  time = y + "-" + m + "-" + d + " " + h + ":" + mm + ":" + ss;
  return time;
};

Vue.prototype.$htmlUnescape  = function (str) {
  var parser = new DOMParser();
  var doc = parser.parseFromString(str, 'text/html');
  return doc.documentElement.textContent;
}

